import {Component} from 'react'
import propTypes from 'prop-types';
class LoginForm extends Component{
    constructor(props){

         
        console.log(1111111111,props);
        super();

      
    }
    static propTypes={
        id:propTypes.number
    }
    static defaultProps={
         age:18
    }
    close=(val)=>{

    
        return ()=>{
          //  alert(val);

            this.props.getData(val);
        }
       
    }
    login=()=>{

        const {username}=this;

    
        console.log(username.value, this.pwd.value);
       
    }
    componentDidMount(){
        //页面挂载完成勾子函数
        
        // this.username.value="admin";
    }
    render(){

        return(
            <div className='subbox'>子组件

            账号:<input ref={(ref1)=>this.username=ref1}></input>

            <div>
                <div>

                密码:<input ref={(ref1)=>this.pwd=ref1}></input>
                </div>

                <button onClick={this.login}>登录</button>
            </div>

              {this.props.id}
          
              {this.props.userInfo.name}
              {this.props.age}

              <button onClick={this.close("给父组件传的值")}>给父组件传值</button>
            </div>
        )

    }
}
export default LoginForm;